import java.util.Arrays;
import java.util.Random;

public class TestSort {

    public static void testInserSort(int[] array){
        Arrays.copyOf(array,array.length);
        //拷贝好后有副本，排序表排副本
        long startTime = System.currentTimeMillis();
        test.insertSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("插入排序耗费时间：" +(endTime - startTime));
    }

    public static void testshellSort(int[] array){
        Arrays.copyOf(array,array.length);
        //拷贝好后有副本，排序表排副本
        long startTime = System.currentTimeMillis();
        test.shellSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("希尔排序耗费时间：" +(endTime - startTime));
    }

    public static void testSelectSort(int[] array){
        Arrays.copyOf(array,array.length);
        //拷贝好后有副本，排序表排副本
        long startTime = System.currentTimeMillis();
        test.selectSort2(array);
        long endTime = System.currentTimeMillis();
        System.out.println("选择排序耗费时间：" +(endTime - startTime));
    }


    public static void testHeapSort(int[] array){
        Arrays.copyOf(array,array.length);
        //拷贝好后有副本，排序表排副本
        long startTime = System.currentTimeMillis();
        test.heapSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("堆排序耗费时间：" +(endTime - startTime));
    }

    public static void testQuickSort(int[] array){
        Arrays.copyOf(array,array.length);
        //拷贝好后有副本，排序表排副本
        long startTime = System.currentTimeMillis();
        test.quickSort2(array);
        long endTime = System.currentTimeMillis();
        System.out.println("挖坑排序耗费时间：" +(endTime - startTime));
    }

    public static void testMergeSort(int[] array){
        Arrays.copyOf(array,array.length);
        //拷贝好后有副本，排序表排副本
        long startTime = System.currentTimeMillis();
        test.mergeSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("归并排序耗费时间：" +(endTime - startTime));
    }

    public static void orderArray(int[] array){
        for (int i = 0;i < array.length; i++){
            /*array[i] = array.length-i;*/
            array[i] = i;
        }
    }

    public static void notOrderArray(int[] array){
        //生成随机数组，乱序
        Random random = new Random();
        for (int i = 0;i < array.length; i++){
            array[i] = random.nextInt(100_0000);
        }
    }



    public static void main(String[] args) {
        int[] array = new int[100_0000];
        //orderArray(array);
        notOrderArray(array);//无序
        //testInserSort(array);
        //testshellSort(array);
        //testSelectSort(array);
        //testHeapSort(array);
        testQuickSort(array);
        testMergeSort(array);

    }
}
